<template>
  <el-dialog :close-on-click-modal='false' v-drag :title="$t('添加')" :v-if="dialogVisible" :visible.sync="dialogVisible" append-to-body width="500px" @close='close' top="10vh">
    <div class="dialogContentBox">
      <el-table size='mini' ref="multipleTable" :data="assetList" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
        <el-table-column type="selection" align='center' width="55"></el-table-column>
        <el-table-column prop="name" :label="$t('名称')" align='center' min-width="100">
          <template slot-scope="scope">
            <tooltip :copyText="scope.row.name" class="wid190">
            </tooltip>
          </template>
        </el-table-column>
        <el-table-column prop="ip" label="IP" align='center' min-width="100">
          <template slot-scope="scope">
            <tooltip :copyText="scope.row.ip" class="wid190">
            </tooltip>
          </template>
          <!-- {{scope.row.ip?scope.row.ip.join(','):''}} -->
        </el-table-column>
      </el-table>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submit" class="innerAddSubmit">{{$t('确 定')}}</el-button>
      <el-button @click="close" class="innerAddClose">{{$t('取 消')}}</el-button>
    </span>
  </el-dialog>
</template>
<script>
import { getAssetArray } from '@/api/list/assets/assetobject'
export default {
  name: 'AssetGroupDialog',
  data () {
    return {
      dialogVisible: false,
      assetList: [],
      assetSelect: []
    }
  },
  methods: {
    init () {
      this.dialogVisible = true
      getAssetArray().then(res => {
        if (res.status === 0) {
          this.assetList = res.info
        }
      })
    },
    submit () {
      this.$emit('addAssetForTable', this.assetSelect)
      this.close()
    },
    close () {
      this.dialogVisible = false
      this.assetList = []
      this.assetSelect = []
    },
    handleSelectionChange (data) {
      this.assetSelect = data
    }
  }
}
</script>
<style scoped>
.dialogContentBox {
  max-height: calc(80vh - 184px);
  overflow-y: auto;
}
</style>
